package studio.banner.reference.service;


import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.web.multipart.MultipartFile;
import studio.banner.reference.entity.Document;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public interface DocumentService extends IService<Document> {

    /**
     * 添加文献
     *
     * @param document
     * @return
     */
    boolean createDocument(Document document);


    /**
     * 批量添加文献
     *
     * @param docList
     * @param aggregateId
     * @return
     */
    boolean createDocumentList(List<String> docList, Integer aggregateId);

    /**
     * 删除文献
     *
     * @param documentId
     * @return
     */
    boolean deleteDocument(Long documentId);

    /**
     * 删除，通过文献集Id
     *
     * @param id
     * @return
     */
    boolean removeByAggregateId(Integer id);

    /**
     * 批量删除文献
     *
     * @param documentIds
     * @param userId
     * @return
     */
    boolean deleteDocumentList(List<Long> documentIds, Integer userId);


    /**
     * 修改文献
     *
     * @param documentContent
     * @param documentId
     * @return
     */
    boolean updateContent(String documentContent, Long documentId);

    /**
     * 查找文献(关键词)(模糊)/时间降序
     *
     * @param keyWord
     * @param userId
     * @return
     */
    List<Document> getDocumentByKeyword(String keyWord, Integer userId);

    List<Document> listByAggregateId(Integer aggregateId);

    /**
     * 格式检验
     *
     * @param documentContent
     * @return
     */
    boolean documentCheck(String documentContent);


    /**
     * 解析word文献
     *
     * @param file
     * @return Document的集合
     * @throws IOException
     */
    List<Document> wordImport(MultipartFile file) throws IOException;


    /**
     * 下载文献
     *
     * @param documentIds
     * @param response
     * @throws IOException
     */
    void downloadDocuments(List<Integer> documentIds, HttpServletResponse response) throws IOException;

}
